JavaScript

A5.audio.Playervolume Method

Syntax

A5.audio.Player.volume(volume)

Arguments

volumenumber

Volume to set, a value between 0.0 and 1.0.

Description

Set the volume of the audio playback.

Example: Adjusting the Volume for the AudioPlayer Control

The UX Component AudioPlayer control's JavaScript object can be used to adjust the audio volume. The _play property of the object contains the audio player class methods. The JavaScript is an example of a function that could be used to increase or decrease the audio volume for an AudioPlayer control:

function incrementVolume (increaseVolume) {
    // Get the object for the AudioPlayer Control:
    var audioObj = {dialog.object}.getControl('AUDIOPLAYER');

    if (audioObj) {
        // get the current volume level:
        var state = audioObj._play.getState();
        var volume = state.volume;

        if (increaseVolume === true) {
            // increase the volume for the AudioPlayer
            volume = Math.min(1.0,volume + 0.1);
        } else {
            // decrease the volume for the AudioPlayer
            volume = Math.max(0.0,volume - 0.1);
        }

        // set the volume
        audioObj._play.volume(volume);
    }
}
The AudioRecorderAndPlayer control's JavaScript object also has a _play property containing methods for the audio player class.

See Also